home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / tutorials / custEducation / opengl2 / examples / rasterops / letterF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  3.0 KB  |  131 lines

  1. /*
  2.  * Copyright 1995, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. /* letterF.c
  19.  *    Draws the bitmapped letter F on the screen (several times).
  20.  *    This demonstrates use of the glBitmap() call.
  21.  */
  22. #include <GL/gl.h>
  23. #include <GL/glu.h>
  24. #include <GL/glut.h>
  25.  
  26. #include <math.h>
  27. #include <stdio.h>
  28.  
  29. /*  Function Prototypes  */
  30.  
  31. GLvoid  initgfx( GLvoid );
  32. GLvoid  drawScene( GLvoid );
  33. GLvoid  reshape( GLsizei, GLsizei );
  34. GLvoid  keyboard( GLubyte, GLint, GLint );
  35.  
  36. /* Global Definitions */
  37.  
  38. #define KEY_ESC    27    /* ascii value for the escape key */
  39.  
  40. /* Global Variables */
  41.  
  42. static GLsizei  winWidth, winHeight;
  43.  
  44. static GLubyte letterF[64] = {
  45.     0xc0, 0x00, 0x00, 0x00,
  46.     0xc0, 0x00, 0x00, 0x00,
  47.     0xc0, 0x00, 0x00, 0x00,
  48.     0xc0, 0x00, 0x00, 0x00,
  49.     0xc0, 0x00, 0x00, 0x00,
  50.     0xff, 0x00, 0x00, 0x00,
  51.     0xff, 0x00, 0x00, 0x00,
  52.     0xc0, 0x00, 0x00, 0x00,
  53.     0xc0, 0x00, 0x00, 0x00,
  54.     0xc0, 0x00, 0x00, 0x00,
  55.     0xff, 0xc0, 0x00, 0x00,
  56.     0xff, 0xc0, 0x00, 0x00,
  57.     0x00, 0x00, 0x00, 0x00,
  58.     0x00, 0x00, 0x00, 0x00,
  59.     0x00, 0x00, 0x00, 0x00,
  60.     0x00, 0x00, 0x00, 0x00
  61. };
  62.  
  63. GLvoid
  64. main ( int argc, char *argv[])
  65. {
  66.     GLsizei  width, height;
  67.  
  68.     glutInit( &argc, argv );
  69.  
  70.     width = glutGet(GLUT_SCREEN_WIDTH); 
  71.     height = glutGet(GLUT_SCREEN_HEIGHT);
  72.     winWidth = width / 2;
  73.     winHeight = height / 2;
  74.     glutInitWindowPosition( width / 4, height / 4); 
  75.     glutInitWindowSize( winWidth, winHeight );
  76.     glutInitDisplayMode( GLUT_RGBA );
  77.     glutCreateWindow( argv[0] );
  78.  
  79.     glutKeyboardFunc( keyboard );
  80.     glutReshapeFunc( reshape );
  81.     glutDisplayFunc( drawScene );
  82.  
  83.     glutMainLoop();
  84. }
  85.  
  86. void
  87. initgfx( void )
  88. {
  89.     glClearColor( 0.0, 0.0, 0.0, 1.0 );
  90. }
  91.  
  92. GLvoid 
  93. keyboard( GLubyte key, GLint x, GLint y )
  94. {
  95.     switch (key) {
  96.     case KEY_ESC:    /* Exit whenever the Escape key is pressed */
  97.         exit(0);
  98.     }
  99. }
  100.  
  101. GLvoid
  102. reshape( GLsizei width, GLsizei height )
  103. {
  104.     glViewport( 0, 0, width, height );
  105.  
  106.     winWidth = width;
  107.     winHeight = height;
  108.  
  109.     glMatrixMode( GL_PROJECTION );
  110.     glLoadIdentity();
  111.     gluOrtho2D( 0.0, (GLdouble) width, 0.0, (GLdouble) height );
  112.     glMatrixMode( GL_MODELVIEW );
  113.     glLoadIdentity();
  114.     glTranslatef( 0.375, 0.375, 0.0 );
  115. }
  116.  
  117. GLvoid
  118. drawScene( GLvoid )
  119. {
  120.     GLsizei  width, height;
  121.  
  122.     glClear( GL_COLOR_BUFFER_BIT );
  123.  
  124.     glColor3f( 1.0, 1.0, 1.0 );
  125.     glRasterPos2i( winWidth/2, winHeight/2 );
  126.     glBitmap( 10, 12, 0.0, 0.0, 12.0, 0.0, letterF );
  127.     glBitmap( 10, 12, 0.0, 0.0, 12.0, 0.0, letterF );
  128.     glBitmap( 10, 12, 0.0, 0.0, 12.0, 0.0, letterF );
  129.     glFlush();
  130. }
  131.